package com.bajiao.service.store.impl;

import com.bajiao.common.util.FastJsonHelper;
import com.bajiao.entity.store.StorePermission;
import com.bajiao.mapper.store.StorePermissionMapper;
import com.bajiao.service.store.StorePermissionService;
import com.bajiao.vo.store.StorePermissionResponse;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @Description: 店铺权限
 * @Author: FanJq
 * @Date:   2024-12-24
 * @Version: V1.0
 */
@Service
public class StorePermissionServiceImpl extends ServiceImpl<StorePermissionMapper, StorePermission> implements StorePermissionService {

    /**
     * @Description
     * 获取权限列表
     * @date 2024/12/28 14:15
     * @author FanJq
     * @param
     * @return {@link List< StorePermissionResponse>}
    */
    @Override
    public List<StorePermissionResponse> getPermissionList() {
        List<StorePermission> permissionList = super.lambdaQuery().orderByAsc(StorePermission::getCreateTime).list();
        List<StorePermissionResponse> responseList = permissionList.stream().map(p -> {
            StorePermissionResponse response = FastJsonHelper.beanToBean(p, StorePermissionResponse.class);
            return response;
        }).collect(Collectors.toList());
        return responseList;
    }
}
